if ( SERVER ) then

	AddCSLuaFile( "shared.lua" )
end

if ( CLIENT ) then

	SWEP.PrintName			= "SPD Healer"			
	SWEP.Author				= "Ltp0wer"
	SWEP.Slot				= 1
	SWEP.SlotPos			= 4
	SWEP.Instructions	= "Primary Fire Heals the Ent you are looking at"
	SWEP.Description	= "Heal Gun"
	SWEP.HoldType			= "pistol"
	
end


SWEP.Spawnable			= true
SWEP.AdminSpawnable		= true

SWEP.ViewModel			= "models/weapons/v_pistol.mdl"
SWEP.WorldModel			= "models/weapons/w_pistol.mdl"
SWEP.ViewModelFlip		= false

SWEP.Weight			= 5
SWEP.AutoSwitchTo		= true
SWEP.AutoSwitchFrom		= false

SWEP.Primary.DefaultClip	= -1
SWEP.Primary.Automatic		= true
SWEP.Primary.Ammo		= -1

function SWEP:Initialize()
end

function SWEP:Equip(ply)
end

function SWEP:Reload() 
end 

function SWEP:PrimaryAttack()
    self.Weapon:SetNextPrimaryFire( CurTime() + 0.5 ) 
    local ent = self.Owner:GetEyeTrace().Entity
	local ConstrainedEntities = constraint.GetAllConstrainedEntities(ent) 
	if ent:IsValid() and
	spd[ent:EntIndex()]	then
	    local mass = ent:GetPhysicsObject():GetMass()
      		local colmod = spd[ent:EntIndex()] / mass
			if (!spd[ent:EntIndex()]>=mass) then 
			spd[ent:EntIndex()] =1 spd[ent:EntIndex()]+50
			ent:SetColor(255, colmod * 255, colmod * 255, 255)
			end
		if ent:IsConstrained() then
			for k, ent in pairs( ConstrainedEntities ) do
			    if ent:IsValid() and spd[ConstrainedEntities[k]:EntIndex()] then
				local mass2 = ConstrainedEntities[k]:GetPhysicsObject():GetMass()
					if (!spd[ConstrainedEntities[k]:EntIndex()]>=mass2) then  
					spd[ConstrainedEntities[k]:EntIndex()] = spd[ConstrainedEntities[k]:EntIndex()]+50
					local colmod = spd[ent:EntIndex()] / mass2
					ConstrainedEntities[k]:SetColor(255, colmod * 255, colmod * 255, 255)
					end
				end
		    end
		end
	end	
end

function SWEP:SecondaryAttack()
end